<?php
/**
 * @author Feng
 * @date 2012-6-16
 */
class collection_rule_concept extends system_concept_abstract {
	
	public function init() {
		$this->setRowClass('collection_rule_row');
		$this->setModel('collection_rule_model', 'rule');
		$this->setModelCols('rule', array('id', 'type', 'rule'));
	}
	
	public function save($row) {
		if(!$row->get('rule')) {
			$row->setRule(serialize(array()));
		}
		if($row->getId()) {
			$this->getModel('rule')->update($row->getModelData('rule'), array('id = ?' => $row->getId()));
		} else {
			$id = $this->getModel('rule')->insert($row->getModelData('rule'));
			$row->setId($id);
		}
		return $row;
	}
}
